package avicit.bdp.dcs.detail.dto;

import avicit.bdp.common.base.BaseDTO;
import avicit.platform6.core.annotation.log.FieldRemark;
import avicit.platform6.core.annotation.log.Id;
import avicit.platform6.core.annotation.log.LogField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * @金航数码科技有限责任公司
 * @作者：developer
 * @邮箱：developer@avic-digital.com
 * @创建时间： 2020-08-03 11:15
 * @类说明：数据迁移同步表结构明细实体类
 * @修改记录：
 */
@ApiModel(value = "TaskTableDetailDTO", description = "bdp_dcs_task_table_detail")
@Table(name = "bdp_dcs_task_table_detail")
public class TaskTableDetailDTO extends BaseDTO {

    private static final long serialVersionUID = 1L;

    // 主键
    @Id
    @LogField
    @ApiModelProperty(value = "主键")
    @FieldRemark(column = "id", field = "id", name = "id")
    @javax.persistence.Id
    @Column(name = "id")
    private String id;

    // 任务id
    @LogField
    @ApiModelProperty(value = "任务id")
    @FieldRemark(column = "task_id", field = "taskId", name = "任务ID")
    @Column(name = "task_id")
    private String taskId;

    // 源表名
    @LogField
    @ApiModelProperty(value = "源表名")
    @FieldRemark(column = "src_table_name", field = "srcTableName", name = "源表名")
    @Column(name = "src_table_name")
    private String srcTableName;

    // 目标表名
    @LogField
    @ApiModelProperty(value = "目标表名")
    @FieldRemark(column = "dst_table_name", field = "dstTableName", name = "目标表名")
    @Column(name = "dst_table_name")
    private String dstTableName;

    // 源库名
    @ApiModelProperty(value = "源库名")
    @Transient
    private String srcSchemaName;

    // 目标库名
    @ApiModelProperty(value = "目标库名")
    @Transient
    private String dstSchemaName;

    // 状态，未启动：23，执行中：1，执行失败：6，暂停中：3，完成：7
    @LogField
    @ApiModelProperty(value = "状态，未启动：23，执行中：1，执行失败：6，暂停中：3，完成：7")
    @FieldRemark(column = "task_status", field = "taskStatus", name = "状态")
    @Column(name = "task_status")
    private Integer taskStatus;

    // 创建表语法
    @LogField
    @ApiModelProperty(value = "创建表语法")
    @FieldRemark(column = "create_sql", field = "createSql", name = "创建表语法")
    @Column(name = "create_sql")
    private String createSql;

    // 组织机构代码
    @ApiModelProperty(value = "组织机构代码")
    @FieldRemark(column = "org_identity", field = "orgIdentity", name = "组织机构代码")
    @Column(name = "org_identity")
    private String orgIdentity;

    // 密级
    @ApiModelProperty(value = "密级")
    @FieldRemark(column = "secret_level", field = "secretLevel", name = "密级")
    @Column(name = "secret_level")
    private String secretLevel;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTaskId() {
        return taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    public String getSrcTableName() {
        return srcTableName;
    }

    public void setSrcTableName(String srcTableName) {
        this.srcTableName = srcTableName;
    }

    public String getDstTableName() {
        return dstTableName;
    }

    public void setDstTableName(String dstTableName) {
        this.dstTableName = dstTableName;
    }

    public String getSrcSchemaName() {
        return srcSchemaName;
    }

    public void setSrcSchemaName(String srcSchemaName) {
        this.srcSchemaName = srcSchemaName;
    }

    public String getDstSchemaName() {
        return dstSchemaName;
    }

    public void setDstSchemaName(String dstSchemaName) {
        this.dstSchemaName = dstSchemaName;
    }

    public Integer getTaskStatus() {
        return taskStatus;
    }

    public void setTaskStatus(Integer taskStatus) {
        this.taskStatus = taskStatus;
    }

    public String getCreateSql() {
        return createSql;
    }

    public void setCreateSql(String createSql) {
        this.createSql = createSql;
    }

    @Override
    public String getOrgIdentity() {
        return orgIdentity;
    }

    @Override
    public void setOrgIdentity(String orgIdentity) {
        this.orgIdentity = orgIdentity;
    }

    @Override
    public String getSecretLevel() {
        return secretLevel;
    }

    @Override
    public void setSecretLevel(String secretLevel) {
        this.secretLevel = secretLevel;
    }

    @Override
    public String getLogFormName() {
        if (StringUtils.isEmpty(super.logFormName)) {
            return "表明细模块";
        } else {
            return super.logFormName;
        }
    }

    @Override
    public String getLogTitle() {
        if (StringUtils.isEmpty(super.logTitle)) {
            return "表明细";
        } else {
            return super.logTitle;
        }
    }

    public TaskTableDetailDTO() {

    }

    public TaskTableDetailDTO(Builder builder) {
        this.id = builder.id;
        this.taskId = builder.taskId;
        this.srcTableName = builder.srcTableName;
        this.dstTableName = builder.dstTableName;
        this.srcSchemaName = builder.srcSchemaName;
        this.dstSchemaName = builder.dstSchemaName;
        this.taskStatus = builder.taskStatus;
        this.createSql = builder.createSql;
        this.orgIdentity = builder.orgIdentity;
        this.secretLevel = builder.secretLevel;
    }

    public static Builder builder() {
        return new Builder();
    }

    public static final class Builder{
        private String id;
        private String taskId;
        private String srcTableName;
        private String dstTableName;
        private String srcSchemaName;
        private String dstSchemaName;
        private Integer taskStatus;
        private String createSql;
        private String orgIdentity;
        private String secretLevel;
        public Builder id(String id) {
            this.id = id;
            return this;
        }
        public Builder taskId(String taskId) {
            this.taskId = taskId;
            return this;
        }
        public Builder srcTableName(String srcTableName) {
            this.srcTableName = srcTableName;
            return this;
        }
        public Builder dstTableName(String dstTableName) {
            this.dstTableName = dstTableName;
            return this;
        }
        public Builder srcSchemaName(String srcSchemaName) {
            this.srcSchemaName = srcSchemaName;
            return this;
        }
        public Builder dstSchemaName(String dstSchemaName) {
            this.dstSchemaName = dstSchemaName;
            return this;
        }
        public Builder taskStatus(Integer taskStatus) {
            this.taskStatus = taskStatus;
            return this;
        }
        public Builder createSql(String createSql) {
            this.createSql = createSql;
            return this;
        }
        public Builder orgIdentity(String orgIdentity) {
            this.orgIdentity = orgIdentity;
            return this;
        }
        public Builder secretLevel(String secretLevel) {
            this.secretLevel = secretLevel;
            return this;
        }
        public TaskTableDetailDTO build() {
            return new TaskTableDetailDTO(this);
        }
    }

}